#!/usr/bin/perl
#index.cgi
#list all webmin users

require './setpass-lib.pl';

&header($text{'index_title'}, "", "index", 0, 1);
#print("<hr>\n");
print("<form name='indexform' action=index.cgi target=_top method=post onsubmit='document.forms[0].submit_ok.disabled=true;'> \n");
print("<input type='hidden' name=txt_oldusername value=$remote_user>");

print("<table class=mode1 border=0> <tr>\n");
print("<td width=100> <b>$text{'index_lable_username'}</b> </td>\n");
print("<td> $remote_user</td><tr>\n");

print("<tr><td><b> $text{'index_lable_currentpassword'}</b> </td>\n");
print("<td> <input type=password name=txt_currentpassword tableindex=2 maxlength=128 class=text> </td></tr>\n");

print("<tr><td><b> $text{'index_lable_newusername'} </b></td>\n");
print("<td> <input type=text name=txt_newusername value=$remote_user tableindex=3 maxlength=128 class=text> </td></tr>\n");

print("<tr><td><b> $text{'index_lable_newpassword'} </b></td>\n");
print("<td> <input type=password name=txt_newpassword tableindex=3 maxlength=128 class=text> </td></tr>\n");

print("<tr><td><b> $text{'index_lable_confirmnewpassword'}</b></td>\n");
print("<td> <input type=password name=txt_confirmnewpassword tableindex=4 maxlength=128 class=text> </td></tr>\n");

print("</table><p>\n");
#print("<hr>\n");
print "<input type='submit' class='button1' ", "name='submit_ok'", "value=\'$text{'index_submit_ok'}\' onclick=\'return on_submit_ok(\"$text{'error_msg_nousername'}\", \"$text{'error_msg_passwdnotconfirm'}\")\'>\n";

print("</form>\n");


print <<EOF;
<script>

function on_submit_ok(error_msg_noname, error_msg_passwdnoconfirm)
{
	if (document.forms[0].txt_newusername.value == "")
	{
		alert(error_msg_noname);
		return false;
	}

	if (document.forms[0].txt_newpassword.value != document.forms[0].txt_confirmnewpassword.value)
	{
		alert(error_msg_passwdnoconfirm);
		return false;
	}
	
	document.forms[0].action = "setpasswd.cgi";
}

</script>
EOF

&footer("/", $text{'index'});
